import java.util.Arrays;
import java.util.Comparator;

public class Hindex {

    public static int answer(int[] nums){
        Arrays.sort(nums);
        int h=0;
        for (int i = nums.length-1; i >=0 ; i--) {
            if(nums[i]>h){
                h++;
            }

        }
        return h;
    }

    public static void main(String[] args) {
        int[] nums=new int[]{3,0,6,1,5};
        System.out.println(answer(nums));
    }
}
